package com.jxit0573.android.demo.activity;

import android.Manifest;
import android.os.Bundle;
import android.view.View;

import androidx.annotation.Nullable;

import com.google.common.collect.Maps;
import com.jxit0573.android.demo.R;
import com.jxit0573.android.lib.activity.BaseActivity;
import com.jxit0573.android.lib.util.DialogUtils;
import com.tbruyelle.rxpermissions2.RxPermissions;

import java.util.Map;

import io.reactivex.disposables.Disposable;

/**
 * @author jia
 */
public class SplashActivity extends BaseActivity {

    long current;
    private Disposable disposable;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        RxPermissions rxPermissions = new RxPermissions(this);
        disposable = rxPermissions.requestEachCombined(
                Manifest.permission.READ_PHONE_STATE,
                Manifest.permission.WRITE_EXTERNAL_STORAGE,
                Manifest.permission.CAMERA)
                .subscribe(permission -> {
                    if (permission.granted) {
                    } else if (permission.shouldShowRequestPermissionRationale) {
                        DialogUtils.getInstance().showToast(this, "为避免APP使用不正常，请务必允许APP获取相关手机权限！");
                    } else {
                        DialogUtils.getInstance().showToast(this, "为避免APP使用不正常，请务必允许APP获取所有相关手机权限！");
                    }
                });
    }

    @Override
    protected void onDestroy() {
        if (disposable != null && !disposable.isDisposed()) {
            disposable.dispose();
        }
        super.onDestroy();
    }

    @Override
    public void initView() {

    }

    @Override
    public void initData() {

    }

    @Override
    public void getData() {

    }

    @Override
    public void setData() {

    }

    @Override
    public void onBackPressedSupport() {
        exit();
    }

    @Override
    public void onViewClick(View v) {
        super.onViewClick(v);
        if (v.getId() == R.id.btn_1) {
            Map<String, Object> params = Maps.newHashMapWithExpectedSize(7);
        }
    }

}
